1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.TextView; 26 27 private import gdk.Event; 28 private import gio.MenuModel; 29 private import glib.ConstructionException; 30 private import glib.MemorySlice; 31 private import glib.Str; 32 private import gobject.ObjectG; 33 private import gobject.Signals; 34 private import gtk.ScrollableIF; 35 private import gtk.ScrollableT; 36 private import gtk.TextBuffer; 37 private import gtk.TextChildAnchor; 38 private import gtk.TextIter; 39 private import gtk.TextMark; 40 private import gtk.Widget; 41 private import gtk.c.functions; 42 public import gtk.c.types; 43 private import pango.PgContext; 44 private import pango.PgTabArray; 45 private import std.algorithm; 46 47 48 /** 49 * A widget that displays the contents of a [class@Gtk.TextBuffer]. 50 * 51 *  52 * 53 * You may wish to begin by reading the [conceptual overview](section-text-widget.html), 54 * which gives an overview of all the objects and data types related to the 55 * text widget and how they work together. 56 * 57 * ## CSS nodes 58 * 59 * ``` 60 * textview.view 61 * ├── border.top 62 * ├── border.left 63 * ├── text 64 * │ ╰── [selection] 65 * ├── border.right 66 * ├── border.bottom 67 * ╰── [window.popup] 68 * ``` 69 * 70 * `GtkTextView` has a main css node with name textview and style class .view, 71 * and subnodes for each of the border windows, and the main text area, 72 * with names border and text, respectively. The border nodes each get 73 * one of the style classes .left, .right, .top or .bottom. 74 * 75 * A node representing the selection will appear below the text node. 76 * 77 * If a context menu is opened, the window node will appear as a subnode 78 * of the main node. 79 * 80 * ## Accessibility 81 * 82 * `GtkTextView` uses the %GTK_ACCESSIBLE_ROLE_TEXT_BOX role. 83 */ 84 public class TextView : Widget, ScrollableIF 85 { 86 /** the main Gtk struct */ 87 protected GtkTextView* gtkTextView; 88 89 /** Get the main Gtk struct */ 90 public GtkTextView* getTextViewStruct(bool transferOwnership = false) 91 { 92 if (transferOwnership) 93 ownedRef = false; 94 return gtkTextView; 95 } 96 97 /** the main Gtk struct as a void* */ 98 protected override void* getStruct() 99 { 100 return cast(void*)gtkTextView; 101 } 102 103 /** 104 * Sets our main struct and passes it to the parent class. 105 */ 106 public this (GtkTextView* gtkTextView, bool ownedRef = false) 107 { 108 this.gtkTextView = gtkTextView; 109 super(cast(GtkWidget*)gtkTextView, ownedRef); 110 } 111 112 // add the Scrollable capabilities 113 mixin ScrollableT!(GtkTextView); 114 115 116 /** */ 117 public static GType getType() 118 { 119 return gtk_text_view_get_type(); 120 } 121 122 /** 123 * Creates a new `GtkTextView`. 124 * 125 * If you don’t call [method@Gtk.TextView.set_buffer] before using the 126 * text view, an empty default buffer will be created for you. Get the 127 * buffer with [method@Gtk.TextView.get_buffer]. If you want to specify 128 * your own buffer, consider [ctor@Gtk.TextView.new_with_buffer]. 129 * 130 * Returns: a new `GtkTextView` 131 * 132 * Throws: ConstructionException GTK+ fails to create the object. 133 */ 134 public this() 135 { 136 auto __p = gtk_text_view_new(); 137 138 if(__p is null) 139 { 140 throw new ConstructionException("null returned by new"); 141 } 142 143 this(cast(GtkTextView*) __p); 144 } 145 146 /** 147 * Creates a new `GtkTextView` widget displaying the buffer @buffer. 148 * 149 * One buffer can be shared among many widgets. @buffer may be %NULL 150 * to create a default buffer, in which case this function is equivalent 151 * to [ctor@Gtk.TextView.new]. The text view adds its own reference count 152 * to the buffer; it does not take over an existing reference. 153 * 154 * Params: 155 * buffer = a `GtkTextBuffer` 156 * 157 * Returns: a new `GtkTextView`. 158 * 159 * Throws: ConstructionException GTK+ fails to create the object. 160 */ 161 public this(TextBuffer buffer) 162 { 163 auto __p = gtk_text_view_new_with_buffer((buffer is null) ? null : buffer.getTextBufferStruct()); 164 165 if(__p is null) 166 { 167 throw new ConstructionException("null returned by new_with_buffer"); 168 } 169 170 this(cast(GtkTextView*) __p); 171 } 172 173 /** 174 * Adds a child widget in the text buffer, at the given @anchor. 175 * 176 * Params: 177 * child = a `GtkWidget` 178 * anchor = a `GtkTextChildAnchor` in the `GtkTextBuffer` for @text_view 179 */ 180 public void addChildAtAnchor(Widget child, TextChildAnchor anchor) 181 { 182 gtk_text_view_add_child_at_anchor(gtkTextView, (child is null) ? null : child.getWidgetStruct(), (anchor is null) ? null : anchor.getTextChildAnchorStruct()); 183 } 184 185 /** 186 * Adds @child at a fixed coordinate in the `GtkTextView`'s text window. 187 * 188 * The @xpos and @ypos must be in buffer coordinates (see 189 * [method@Gtk.TextView.get_iter_location] to convert to 190 * buffer coordinates). 191 * 192 * @child will scroll with the text view. 193 * 194 * If instead you want a widget that will not move with the 195 * `GtkTextView` contents see `GtkOverlay`. 196 * 197 * Params: 198 * child = a `GtkWidget` 199 * xpos = X position of child in window coordinates 200 * ypos = Y position of child in window coordinates 201 */ 202 public void addOverlay(Widget child, int xpos, int ypos) 203 { 204 gtk_text_view_add_overlay(gtkTextView, (child is null) ? null : child.getWidgetStruct(), xpos, ypos); 205 } 206 207 /** 208 * Moves the given @iter backward by one display (wrapped) line. 209 * 210 * A display line is different from a paragraph. Paragraphs are 211 * separated by newlines or other paragraph separator characters. 212 * Display lines are created by line-wrapping a paragraph. If 213 * wrapping is turned off, display lines and paragraphs will be the 214 * same. Display lines are divided differently for each view, since 215 * they depend on the view’s width; paragraphs are the same in all 216 * views, since they depend on the contents of the `GtkTextBuffer`. 217 * 218 * Params: 219 * iter = a `GtkTextIter` 220 * 221 * Returns: %TRUE if @iter was moved and is not on the end iterator 222 */ 223 public bool backwardDisplayLine(TextIter iter) 224 { 225 return gtk_text_view_backward_display_line(gtkTextView, (iter is null) ? null : iter.getTextIterStruct()) != 0; 226 } 227 228 /** 229 * Moves the given @iter backward to the next display line start. 230 * 231 * A display line is different from a paragraph. Paragraphs are 232 * separated by newlines or other paragraph separator characters. 233 * Display lines are created by line-wrapping a paragraph. If 234 * wrapping is turned off, display lines and paragraphs will be the 235 * same. Display lines are divided differently for each view, since 236 * they depend on the view’s width; paragraphs are the same in all 237 * views, since they depend on the contents of the `GtkTextBuffer`. 238 * 239 * Params: 240 * iter = a `GtkTextIter` 241 * 242 * Returns: %TRUE if @iter was moved and is not on the end iterator 243 */ 244 public bool backwardDisplayLineStart(TextIter iter) 245 { 246 return gtk_text_view_backward_display_line_start(gtkTextView, (iter is null) ? null : iter.getTextIterStruct()) != 0; 247 } 248 249 /** 250 * Converts buffer coordinates to window coordinates. 251 * 252 * Params: 253 * win = a `GtkTextWindowType` 254 * bufferX = buffer x coordinate 255 * bufferY = buffer y coordinate 256 * windowX = window x coordinate return location 257 * windowY = window y coordinate return location 258 */ 259 public void bufferToWindowCoords(GtkTextWindowType win, int bufferX, int bufferY, out int windowX, out int windowY) 260 { 261 gtk_text_view_buffer_to_window_coords(gtkTextView, win, bufferX, bufferY, &windowX, &windowY); 262 } 263 264 /** 265 * Moves the given @iter forward by one display (wrapped) line. 266 * 267 * A display line is different from a paragraph. Paragraphs are 268 * separated by newlines or other paragraph separator characters. 269 * Display lines are created by line-wrapping a paragraph. If 270 * wrapping is turned off, display lines and paragraphs will be the 271 * same. Display lines are divided differently for each view, since 272 * they depend on the view’s width; paragraphs are the same in all 273 * views, since they depend on the contents of the `GtkTextBuffer`. 274 * 275 * Params: 276 * iter = a `GtkTextIter` 277 * 278 * Returns: %TRUE if @iter was moved and is not on the end iterator 279 */ 280 public bool forwardDisplayLine(TextIter iter) 281 { 282 return gtk_text_view_forward_display_line(gtkTextView, (iter is null) ? null : iter.getTextIterStruct()) != 0; 283 } 284 285 /** 286 * Moves the given @iter forward to the next display line end. 287 * 288 * A display line is different from a paragraph. Paragraphs are 289 * separated by newlines or other paragraph separator characters. 290 * Display lines are created by line-wrapping a paragraph. If 291 * wrapping is turned off, display lines and paragraphs will be the 292 * same. Display lines are divided differently for each view, since 293 * they depend on the view’s width; paragraphs are the same in all 294 * views, since they depend on the contents of the `GtkTextBuffer`. 295 * 296 * Params: 297 * iter = a `GtkTextIter` 298 * 299 * Returns: %TRUE if @iter was moved and is not on the end iterator 300 */ 301 public bool forwardDisplayLineEnd(TextIter iter) 302 { 303 return gtk_text_view_forward_display_line_end(gtkTextView, (iter is null) ? null : iter.getTextIterStruct()) != 0; 304 } 305 306 /** 307 * Returns whether pressing the <kbd>Tab</kbd> key inserts a tab characters. 308 * 309 * See [method@Gtk.TextView.set_accepts_tab]. 310 * 311 * Returns: %TRUE if pressing the Tab key inserts a tab character, 312 * %FALSE if pressing the Tab key moves the keyboard focus. 313 */ 314 public bool getAcceptsTab() 315 { 316 return gtk_text_view_get_accepts_tab(gtkTextView) != 0; 317 } 318 319 /** 320 * Gets the bottom margin for text in the @text_view. 321 * 322 * Returns: bottom margin in pixels 323 */ 324 public int getBottomMargin() 325 { 326 return gtk_text_view_get_bottom_margin(gtkTextView); 327 } 328 329 /** 330 * Returns the `GtkTextBuffer` being displayed by this text view. 331 * 332 * The reference count on the buffer is not incremented; the caller 333 * of this function won’t own a new reference. 334 * 335 * Returns: a `GtkTextBuffer` 336 */ 337 public TextBuffer getBuffer() 338 { 339 auto __p = gtk_text_view_get_buffer(gtkTextView); 340 341 if(__p is null) 342 { 343 return null; 344 } 345 346 return ObjectG.getDObject!(TextBuffer)(cast(GtkTextBuffer*) __p); 347 } 348 349 /** 350 * Determine the positions of the strong and weak cursors if the 351 * insertion point is at @iter. 352 * 353 * The position of each cursor is stored as a zero-width rectangle. 354 * The strong cursor location is the location where characters of 355 * the directionality equal to the base direction of the paragraph 356 * are inserted. The weak cursor location is the location where 357 * characters of the directionality opposite to the base direction 358 * of the paragraph are inserted. 359 * 360 * If @iter is %NULL, the actual cursor position is used. 361 * 362 * Note that if @iter happens to be the actual cursor position, and 363 * there is currently an IM preedit sequence being entered, the 364 * returned locations will be adjusted to account for the preedit 365 * cursor’s offset within the preedit sequence. 366 * 367 * The rectangle position is in buffer coordinates; use 368 * [method@Gtk.TextView.buffer_to_window_coords] to convert these 369 * coordinates to coordinates for one of the windows in the text view. 370 * 371 * Params: 372 * iter = a `GtkTextIter` 373 * strong = location to store the strong cursor position 374 * weak = location to store the weak cursor position 375 */ 376 public void getCursorLocations(TextIter iter, out GdkRectangle strong, out GdkRectangle weak) 377 { 378 gtk_text_view_get_cursor_locations(gtkTextView, (iter is null) ? null : iter.getTextIterStruct(), &strong, &weak); 379 } 380 381 /** 382 * Find out whether the cursor should be displayed. 383 * 384 * Returns: whether the insertion mark is visible 385 */ 386 public bool getCursorVisible() 387 { 388 return gtk_text_view_get_cursor_visible(gtkTextView) != 0; 389 } 390 391 /** 392 * Returns the default editability of the `GtkTextView`. 393 * 394 * Tags in the buffer may override this setting for some ranges of text. 395 * 396 * Returns: whether text is editable by default 397 */ 398 public bool getEditable() 399 { 400 return gtk_text_view_get_editable(gtkTextView) != 0; 401 } 402 403 /** 404 * Gets the menu model that gets added to the context menu 405 * or %NULL if none has been set. 406 * 407 * Returns: the menu model 408 */ 409 public MenuModel getExtraMenu() 410 { 411 auto __p = gtk_text_view_get_extra_menu(gtkTextView); 412 413 if(__p is null) 414 { 415 return null; 416 } 417 418 return ObjectG.getDObject!(MenuModel)(cast(GMenuModel*) __p); 419 } 420 421 /** 422 * Gets a `GtkWidget` that has previously been set as gutter. 423 * 424 * See [method@Gtk.TextView.set_gutter]. 425 * 426 * @win must be one of %GTK_TEXT_WINDOW_LEFT, %GTK_TEXT_WINDOW_RIGHT, 427 * %GTK_TEXT_WINDOW_TOP, or %GTK_TEXT_WINDOW_BOTTOM. 428 * 429 * Params: 430 * win = a `GtkTextWindowType` 431 * 432 * Returns: a `GtkWidget` 433 */ 434 public Widget getGutter(GtkTextWindowType win) 435 { 436 auto __p = gtk_text_view_get_gutter(gtkTextView, win); 437 438 if(__p is null) 439 { 440 return null; 441 } 442 443 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 444 } 445 446 /** 447 * Gets the default indentation of paragraphs in @text_view. 448 * 449 * Tags in the view’s buffer may override the default. 450 * The indentation may be negative. 451 * 452 * Returns: number of pixels of indentation 453 */ 454 public int getIndent() 455 { 456 return gtk_text_view_get_indent(gtkTextView); 457 } 458 459 /** 460 * Gets the `input-hints` of the `GtkTextView`. 461 */ 462 public GtkInputHints getInputHints() 463 { 464 return gtk_text_view_get_input_hints(gtkTextView); 465 } 466 467 /** 468 * Gets the `input-purpose` of the `GtkTextView`. 469 */ 470 public GtkInputPurpose getInputPurpose() 471 { 472 return gtk_text_view_get_input_purpose(gtkTextView); 473 } 474 475 /** 476 * Retrieves the iterator at buffer coordinates @x and @y. 477 * 478 * Buffer coordinates are coordinates for the entire buffer, not just 479 * the currently-displayed portion. If you have coordinates from an 480 * event, you have to convert those to buffer coordinates with 481 * [method@Gtk.TextView.window_to_buffer_coords]. 482 * 483 * Params: 484 * iter = a `GtkTextIter` 485 * x = x position, in buffer coordinates 486 * y = y position, in buffer coordinates 487 * 488 * Returns: %TRUE if the position is over text 489 */ 490 public bool getIterAtLocation(out TextIter iter, int x, int y) 491 { 492 GtkTextIter* outiter = sliceNew!GtkTextIter(); 493 494 auto __p = gtk_text_view_get_iter_at_location(gtkTextView, outiter, x, y) != 0; 495 496 iter = ObjectG.getDObject!(TextIter)(outiter, true); 497 498 return __p; 499 } 500 501 /** 502 * Retrieves the iterator pointing to the character at buffer 503 * coordinates @x and @y. 504 * 505 * Buffer coordinates are coordinates for the entire buffer, not just 506 * the currently-displayed portion. If you have coordinates from an event, 507 * you have to convert those to buffer coordinates with 508 * [method@Gtk.TextView.window_to_buffer_coords]. 509 * 510 * Note that this is different from [method@Gtk.TextView.get_iter_at_location], 511 * which returns cursor locations, i.e. positions between characters. 512 * 513 * Params: 514 * iter = a `GtkTextIter` 515 * trailing = if non-%NULL, location to store 516 * an integer indicating where in the grapheme the user clicked. 517 * It will either be zero, or the number of characters in the grapheme. 518 * 0 represents the trailing edge of the grapheme. 519 * x = x position, in buffer coordinates 520 * y = y position, in buffer coordinates 521 * 522 * Returns: %TRUE if the position is over text 523 */ 524 public bool getIterAtPosition(out TextIter iter, out int trailing, int x, int y) 525 { 526 GtkTextIter* outiter = sliceNew!GtkTextIter(); 527 528 auto __p = gtk_text_view_get_iter_at_position(gtkTextView, outiter, &trailing, x, y) != 0; 529 530 iter = ObjectG.getDObject!(TextIter)(outiter, true); 531 532 return __p; 533 } 534 535 /** 536 * Gets a rectangle which roughly contains the character at @iter. 537 * 538 * The rectangle position is in buffer coordinates; use 539 * [method@Gtk.TextView.buffer_to_window_coords] to convert these 540 * coordinates to coordinates for one of the windows in the text view. 541 * 542 * Params: 543 * iter = a `GtkTextIter` 544 * location = bounds of the character at @iter 545 */ 546 public void getIterLocation(TextIter iter, out GdkRectangle location) 547 { 548 gtk_text_view_get_iter_location(gtkTextView, (iter is null) ? null : iter.getTextIterStruct(), &location); 549 } 550 551 /** 552 * Gets the default justification of paragraphs in @text_view. 553 * 554 * Tags in the buffer may override the default. 555 * 556 * Returns: default justification 557 */ 558 public GtkJustification getJustification() 559 { 560 return gtk_text_view_get_justification(gtkTextView); 561 } 562 563 /** 564 * Gets the default left margin size of paragraphs in the @text_view. 565 * 566 * Tags in the buffer may override the default. 567 * 568 * Returns: left margin in pixels 569 */ 570 public int getLeftMargin() 571 { 572 return gtk_text_view_get_left_margin(gtkTextView); 573 } 574 575 /** 576 * Gets the `GtkTextIter` at the start of the line containing 577 * the coordinate @y. 578 * 579 * @y is in buffer coordinates, convert from window coordinates with 580 * [method@Gtk.TextView.window_to_buffer_coords]. If non-%NULL, 581 * @line_top will be filled with the coordinate of the top edge 582 * of the line. 583 * 584 * Params: 585 * targetIter = a `GtkTextIter` 586 * y = a y coordinate 587 * lineTop = return location for top coordinate of the line 588 */ 589 public void getLineAtY(out TextIter targetIter, int y, out int lineTop) 590 { 591 GtkTextIter* outtargetIter = sliceNew!GtkTextIter(); 592 593 gtk_text_view_get_line_at_y(gtkTextView, outtargetIter, y, &lineTop); 594 595 targetIter = ObjectG.getDObject!(TextIter)(outtargetIter, true); 596 } 597 598 /** 599 * Gets the y coordinate of the top of the line containing @iter, 600 * and the height of the line. 601 * 602 * The coordinate is a buffer coordinate; convert to window 603 * coordinates with [method@Gtk.TextView.buffer_to_window_coords]. 604 * 605 * Params: 606 * iter = a `GtkTextIter` 607 * y = return location for a y coordinate 608 * height = return location for a height 609 */ 610 public void getLineYrange(TextIter iter, out int y, out int height) 611 { 612 gtk_text_view_get_line_yrange(gtkTextView, (iter is null) ? null : iter.getTextIterStruct(), &y, &height); 613 } 614 615 /** 616 * Gets the `PangoContext` that is used for rendering LTR directed 617 * text layouts. 618 * 619 * The context may be replaced when CSS changes occur. 620 * 621 * Returns: a `PangoContext` 622 * 623 * Since: 4.4 624 */ 625 public PgContext getLtrContext() 626 { 627 auto __p = gtk_text_view_get_ltr_context(gtkTextView); 628 629 if(__p is null) 630 { 631 return null; 632 } 633 634 return ObjectG.getDObject!(PgContext)(cast(PangoContext*) __p); 635 } 636 637 /** 638 * Gets whether the `GtkTextView` uses monospace styling. 639 * 640 * Returns: %TRUE if monospace fonts are desired 641 */ 642 public bool getMonospace() 643 { 644 return gtk_text_view_get_monospace(gtkTextView) != 0; 645 } 646 647 /** 648 * Returns whether the `GtkTextView` is in overwrite mode or not. 649 * 650 * Returns: whether @text_view is in overwrite mode or not. 651 */ 652 public bool getOverwrite() 653 { 654 return gtk_text_view_get_overwrite(gtkTextView) != 0; 655 } 656 657 /** 658 * Gets the default number of pixels to put above paragraphs. 659 * 660 * Adding this function with [method@Gtk.TextView.get_pixels_below_lines] 661 * is equal to the line space between each paragraph. 662 * 663 * Returns: default number of pixels above paragraphs 664 */ 665 public int getPixelsAboveLines() 666 { 667 return gtk_text_view_get_pixels_above_lines(gtkTextView); 668 } 669 670 /** 671 * Gets the default number of pixels to put below paragraphs. 672 * 673 * The line space is the sum of the value returned by this function and 674 * the value returned by [method@Gtk.TextView.get_pixels_above_lines]. 675 * 676 * Returns: default number of blank pixels below paragraphs 677 */ 678 public int getPixelsBelowLines() 679 { 680 return gtk_text_view_get_pixels_below_lines(gtkTextView); 681 } 682 683 /** 684 * Gets the default number of pixels to put between wrapped lines 685 * inside a paragraph. 686 * 687 * Returns: default number of pixels of blank space between wrapped lines 688 */ 689 public int getPixelsInsideWrap() 690 { 691 return gtk_text_view_get_pixels_inside_wrap(gtkTextView); 692 } 693 694 /** 695 * Gets the default right margin for text in @text_view. 696 * 697 * Tags in the buffer may override the default. 698 * 699 * Returns: right margin in pixels 700 */ 701 public int getRightMargin() 702 { 703 return gtk_text_view_get_right_margin(gtkTextView); 704 } 705 706 /** 707 * Gets the `PangoContext` that is used for rendering RTL directed 708 * text layouts. 709 * 710 * The context may be replaced when CSS changes occur. 711 * 712 * Returns: a `PangoContext` 713 * 714 * Since: 4.4 715 */ 716 public PgContext getRtlContext() 717 { 718 auto __p = gtk_text_view_get_rtl_context(gtkTextView); 719 720 if(__p is null) 721 { 722 return null; 723 } 724 725 return ObjectG.getDObject!(PgContext)(cast(PangoContext*) __p); 726 } 727 728 /** 729 * Gets the default tabs for @text_view. 730 * 731 * Tags in the buffer may override the defaults. The returned array 732 * will be %NULL if “standard” (8-space) tabs are used. Free the 733 * return value with [method@Pango.TabArray.free]. 734 * 735 * Returns: copy of default tab array, 736 * or %NULL if standard tabs are used; must be freed with 737 * [method@Pango.TabArray.free]. 738 */ 739 public PgTabArray getTabs() 740 { 741 auto __p = gtk_text_view_get_tabs(gtkTextView); 742 743 if(__p is null) 744 { 745 return null; 746 } 747 748 return ObjectG.getDObject!(PgTabArray)(cast(PangoTabArray*) __p, true); 749 } 750 751 /** 752 * Gets the top margin for text in the @text_view. 753 * 754 * Returns: top margin in pixels 755 */ 756 public int getTopMargin() 757 { 758 return gtk_text_view_get_top_margin(gtkTextView); 759 } 760 761 /** 762 * Fills @visible_rect with the currently-visible 763 * region of the buffer, in buffer coordinates. 764 * 765 * Convert to window coordinates with 766 * [method@Gtk.TextView.buffer_to_window_coords]. 767 * 768 * Params: 769 * visibleRect = rectangle to fill 770 */ 771 public void getVisibleRect(out GdkRectangle visibleRect) 772 { 773 gtk_text_view_get_visible_rect(gtkTextView, &visibleRect); 774 } 775 776 /** 777 * Gets the line wrapping for the view. 778 * 779 * Returns: the line wrap setting 780 */ 781 public GtkWrapMode getWrapMode() 782 { 783 return gtk_text_view_get_wrap_mode(gtkTextView); 784 } 785 786 /** 787 * Allow the `GtkTextView` input method to internally handle key press 788 * and release events. 789 * 790 * If this function returns %TRUE, then no further processing should be 791 * done for this key event. See [method@Gtk.IMContext.filter_keypress]. 792 * 793 * Note that you are expected to call this function from your handler 794 * when overriding key event handling. This is needed in the case when 795 * you need to insert your own key handling between the input method 796 * and the default key event handling of the `GtkTextView`. 797 * 798 * ```c 799 * static gboolean 800 * gtk_foo_bar_key_press_event (GtkWidget *widget, 801 * GdkEvent *event) 802 * { 803 * guint keyval; 804 * 805 * gdk_event_get_keyval ((GdkEvent*)event, &keyval); 806 * 807 * if (keyval == GDK_KEY_Return || keyval == GDK_KEY_KP_Enter) 808 * { 809 * if (gtk_text_view_im_context_filter_keypress (GTK_TEXT_VIEW (widget), event)) 810 * return TRUE; 811 * } 812 * 813 * // Do some stuff 814 * 815 * return GTK_WIDGET_CLASS (gtk_foo_bar_parent_class)->key_press_event (widget, event); 816 * } 817 * ``` 818 * 819 * Params: 820 * event = the key event 821 * 822 * Returns: %TRUE if the input method handled the key event. 823 */ 824 public bool imContextFilterKeypress(Event event) 825 { 826 return gtk_text_view_im_context_filter_keypress(gtkTextView, (event is null) ? null : event.getEventStruct()) != 0; 827 } 828 829 /** 830 * Moves a mark within the buffer so that it's 831 * located within the currently-visible text area. 832 * 833 * Params: 834 * mark = a `GtkTextMark` 835 * 836 * Returns: %TRUE if the mark moved (wasn’t already onscreen) 837 */ 838 public bool moveMarkOnscreen(TextMark mark) 839 { 840 return gtk_text_view_move_mark_onscreen(gtkTextView, (mark is null) ? null : mark.getTextMarkStruct()) != 0; 841 } 842 843 /** 844 * Updates the position of a child. 845 * 846 * See [method@Gtk.TextView.add_overlay]. 847 * 848 * Params: 849 * child = a widget already added with [method@Gtk.TextView.add_overlay] 850 * xpos = new X position in buffer coordinates 851 * ypos = new Y position in buffer coordinates 852 */ 853 public void moveOverlay(Widget child, int xpos, int ypos) 854 { 855 gtk_text_view_move_overlay(gtkTextView, (child is null) ? null : child.getWidgetStruct(), xpos, ypos); 856 } 857 858 /** 859 * Move the iterator a given number of characters visually, treating 860 * it as the strong cursor position. 861 * 862 * If @count is positive, then the new strong cursor position will 863 * be @count positions to the right of the old cursor position. 864 * If @count is negative then the new strong cursor position will 865 * be @count positions to the left of the old cursor position. 866 * 867 * In the presence of bi-directional text, the correspondence 868 * between logical and visual order will depend on the direction 869 * of the current run, and there may be jumps when the cursor 870 * is moved off of the end of a run. 871 * 872 * Params: 873 * iter = a `GtkTextIter` 874 * count = number of characters to move (negative moves left, 875 * positive moves right) 876 * 877 * Returns: %TRUE if @iter moved and is not on the end iterator 878 */ 879 public bool moveVisually(TextIter iter, int count) 880 { 881 return gtk_text_view_move_visually(gtkTextView, (iter is null) ? null : iter.getTextIterStruct(), count) != 0; 882 } 883 884 /** 885 * Moves the cursor to the currently visible region of the 886 * buffer. 887 * 888 * Returns: %TRUE if the cursor had to be moved. 889 */ 890 public bool placeCursorOnscreen() 891 { 892 return gtk_text_view_place_cursor_onscreen(gtkTextView) != 0; 893 } 894 895 /** 896 * Removes a child widget from @text_view. 897 * 898 * Params: 899 * child = the child to remove 900 */ 901 public void remove(Widget child) 902 { 903 gtk_text_view_remove(gtkTextView, (child is null) ? null : child.getWidgetStruct()); 904 } 905 906 /** 907 * Ensures that the cursor is shown. 908 * 909 * This also resets the time that it will stay blinking (or 910 * visible, in case blinking is disabled). 911 * 912 * This function should be called in response to user input 913 * (e.g. from derived classes that override the textview's 914 * event handlers). 915 */ 916 public void resetCursorBlink() 917 { 918 gtk_text_view_reset_cursor_blink(gtkTextView); 919 } 920 921 /** 922 * Reset the input method context of the text view if needed. 923 * 924 * This can be necessary in the case where modifying the buffer 925 * would confuse on-going input method behavior. 926 */ 927 public void resetImContext() 928 { 929 gtk_text_view_reset_im_context(gtkTextView); 930 } 931 932 /** 933 * Scrolls @text_view the minimum distance such that @mark is contained 934 * within the visible area of the widget. 935 * 936 * Params: 937 * mark = a mark in the buffer for @text_view 938 */ 939 public void scrollMarkOnscreen(TextMark mark) 940 { 941 gtk_text_view_scroll_mark_onscreen(gtkTextView, (mark is null) ? null : mark.getTextMarkStruct()); 942 } 943 944 /** 945 * Scrolls @text_view so that @iter is on the screen in the position 946 * indicated by @xalign and @yalign. 947 * 948 * An alignment of 0.0 indicates left or top, 1.0 indicates right or 949 * bottom, 0.5 means center. If @use_align is %FALSE, the text scrolls 950 * the minimal distance to get the mark onscreen, possibly not scrolling 951 * at all. The effective screen for purposes of this function is reduced 952 * by a margin of size @within_margin. 953 * 954 * Note that this function uses the currently-computed height of the 955 * lines in the text buffer. Line heights are computed in an idle 956 * handler; so this function may not have the desired effect if it’s 957 * called before the height computations. To avoid oddness, consider 958 * using [method@Gtk.TextView.scroll_to_mark] which saves a point to be 959 * scrolled to after line validation. 960 * 961 * Params: 962 * iter = a `GtkTextIter` 963 * withinMargin = margin as a [0.0,0.5) fraction of screen size 964 * useAlign = whether to use alignment arguments (if %FALSE, 965 * just get the mark onscreen) 966 * xalign = horizontal alignment of mark within visible area 967 * yalign = vertical alignment of mark within visible area 968 * 969 * Returns: %TRUE if scrolling occurred 970 */ 971 public bool scrollToIter(TextIter iter, double withinMargin, bool useAlign, double xalign, double yalign) 972 { 973 return gtk_text_view_scroll_to_iter(gtkTextView, (iter is null) ? null : iter.getTextIterStruct(), withinMargin, useAlign, xalign, yalign) != 0; 974 } 975 976 /** 977 * Scrolls @text_view so that @mark is on the screen in the position 978 * indicated by @xalign and @yalign. 979 * 980 * An alignment of 0.0 indicates left or top, 1.0 indicates right or 981 * bottom, 0.5 means center. If @use_align is %FALSE, the text scrolls 982 * the minimal distance to get the mark onscreen, possibly not scrolling 983 * at all. The effective screen for purposes of this function is reduced 984 * by a margin of size @within_margin. 985 * 986 * Params: 987 * mark = a `GtkTextMark` 988 * withinMargin = margin as a [0.0,0.5) fraction of screen size 989 * useAlign = whether to use alignment arguments (if %FALSE, just 990 * get the mark onscreen) 991 * xalign = horizontal alignment of mark within visible area 992 * yalign = vertical alignment of mark within visible area 993 */ 994 public void scrollToMark(TextMark mark, double withinMargin, bool useAlign, double xalign, double yalign) 995 { 996 gtk_text_view_scroll_to_mark(gtkTextView, (mark is null) ? null : mark.getTextMarkStruct(), withinMargin, useAlign, xalign, yalign); 997 } 998 999 /** 1000 * Sets the behavior of the text widget when the <kbd>Tab</kbd> key is pressed. 1001 * 1002 * If @accepts_tab is %TRUE, a tab character is inserted. If @accepts_tab 1003 * is %FALSE the keyboard focus is moved to the next widget in the focus 1004 * chain. 1005 * 1006 * Params: 1007 * acceptsTab = %TRUE if pressing the Tab key should insert a tab 1008 * character, %FALSE, if pressing the Tab key should move the 1009 * keyboard focus. 1010 */ 1011 public void setAcceptsTab(bool acceptsTab) 1012 { 1013 gtk_text_view_set_accepts_tab(gtkTextView, acceptsTab); 1014 } 1015 1016 /** 1017 * Sets the bottom margin for text in @text_view. 1018 * 1019 * Note that this function is confusingly named. 1020 * In CSS terms, the value set here is padding. 1021 * 1022 * Params: 1023 * bottomMargin = bottom margin in pixels 1024 */ 1025 public void setBottomMargin(int bottomMargin) 1026 { 1027 gtk_text_view_set_bottom_margin(gtkTextView, bottomMargin); 1028 } 1029 1030 /** 1031 * Sets @buffer as the buffer being displayed by @text_view. 1032 * 1033 * The previous buffer displayed by the text view is unreferenced, and 1034 * a reference is added to @buffer. If you owned a reference to @buffer 1035 * before passing it to this function, you must remove that reference 1036 * yourself; `GtkTextView` will not “adopt” it. 1037 * 1038 * Params: 1039 * buffer = a `GtkTextBuffer` 1040 */ 1041 public void setBuffer(TextBuffer buffer) 1042 { 1043 gtk_text_view_set_buffer(gtkTextView, (buffer is null) ? null : buffer.getTextBufferStruct()); 1044 } 1045 1046 /** 1047 * Toggles whether the insertion point should be displayed. 1048 * 1049 * A buffer with no editable text probably shouldn’t have a visible 1050 * cursor, so you may want to turn the cursor off. 1051 * 1052 * Note that this property may be overridden by the 1053 * [property@GtkSettings:gtk-keynav-use-caret] setting. 1054 * 1055 * Params: 1056 * setting = whether to show the insertion cursor 1057 */ 1058 public void setCursorVisible(bool setting) 1059 { 1060 gtk_text_view_set_cursor_visible(gtkTextView, setting); 1061 } 1062 1063 /** 1064 * Sets the default editability of the `GtkTextView`. 1065 * 1066 * You can override this default setting with tags in the buffer, 1067 * using the “editable” attribute of tags. 1068 * 1069 * Params: 1070 * setting = whether it’s editable 1071 */ 1072 public void setEditable(bool setting) 1073 { 1074 gtk_text_view_set_editable(gtkTextView, setting); 1075 } 1076 1077 /** 1078 * Sets a menu model to add when constructing the context 1079 * menu for @text_view. 1080 * 1081 * You can pass %NULL to remove a previously set extra menu. 1082 * 1083 * Params: 1084 * model = a `GMenuModel` 1085 */ 1086 public void setExtraMenu(MenuModel model) 1087 { 1088 gtk_text_view_set_extra_menu(gtkTextView, (model is null) ? null : model.getMenuModelStruct()); 1089 } 1090 1091 /** 1092 * Places @widget into the gutter specified by @win. 1093 * 1094 * @win must be one of %GTK_TEXT_WINDOW_LEFT, %GTK_TEXT_WINDOW_RIGHT, 1095 * %GTK_TEXT_WINDOW_TOP, or %GTK_TEXT_WINDOW_BOTTOM. 1096 * 1097 * Params: 1098 * win = a `GtkTextWindowType` 1099 * widget = a `GtkWidget` 1100 */ 1101 public void setGutter(GtkTextWindowType win, Widget widget) 1102 { 1103 gtk_text_view_set_gutter(gtkTextView, win, (widget is null) ? null : widget.getWidgetStruct()); 1104 } 1105 1106 /** 1107 * Sets the default indentation for paragraphs in @text_view. 1108 * 1109 * Tags in the buffer may override the default. 1110 * 1111 * Params: 1112 * indent = indentation in pixels 1113 */ 1114 public void setIndent(int indent) 1115 { 1116 gtk_text_view_set_indent(gtkTextView, indent); 1117 } 1118 1119 /** 1120 * Sets the `input-hints` of the `GtkTextView`. 1121 * 1122 * The `input-hints` allow input methods to fine-tune 1123 * their behaviour. 1124 * 1125 * Params: 1126 * hints = the hints 1127 */ 1128 public void setInputHints(GtkInputHints hints) 1129 { 1130 gtk_text_view_set_input_hints(gtkTextView, hints); 1131 } 1132 1133 /** 1134 * Sets the `input-purpose` of the `GtkTextView`. 1135 * 1136 * The `input-purpose` can be used by on-screen keyboards 1137 * and other input methods to adjust their behaviour. 1138 * 1139 * Params: 1140 * purpose = the purpose 1141 */ 1142 public void setInputPurpose(GtkInputPurpose purpose) 1143 { 1144 gtk_text_view_set_input_purpose(gtkTextView, purpose); 1145 } 1146 1147 /** 1148 * Sets the default justification of text in @text_view. 1149 * 1150 * Tags in the view’s buffer may override the default. 1151 * 1152 * Params: 1153 * justification = justification 1154 */ 1155 public void setJustification(GtkJustification justification) 1156 { 1157 gtk_text_view_set_justification(gtkTextView, justification); 1158 } 1159 1160 /** 1161 * Sets the default left margin for text in @text_view. 1162 * 1163 * Tags in the buffer may override the default. 1164 * 1165 * Note that this function is confusingly named. 1166 * In CSS terms, the value set here is padding. 1167 * 1168 * Params: 1169 * leftMargin = left margin in pixels 1170 */ 1171 public void setLeftMargin(int leftMargin) 1172 { 1173 gtk_text_view_set_left_margin(gtkTextView, leftMargin); 1174 } 1175 1176 /** 1177 * Sets whether the `GtkTextView` should display text in 1178 * monospace styling. 1179 * 1180 * Params: 1181 * monospace = %TRUE to request monospace styling 1182 */ 1183 public void setMonospace(bool monospace) 1184 { 1185 gtk_text_view_set_monospace(gtkTextView, monospace); 1186 } 1187 1188 /** 1189 * Changes the `GtkTextView` overwrite mode. 1190 * 1191 * Params: 1192 * overwrite = %TRUE to turn on overwrite mode, %FALSE to turn it off 1193 */ 1194 public void setOverwrite(bool overwrite) 1195 { 1196 gtk_text_view_set_overwrite(gtkTextView, overwrite); 1197 } 1198 1199 /** 1200 * Sets the default number of blank pixels above paragraphs in @text_view. 1201 * 1202 * Tags in the buffer for @text_view may override the defaults. 1203 * 1204 * Params: 1205 * pixelsAboveLines = pixels above paragraphs 1206 */ 1207 public void setPixelsAboveLines(int pixelsAboveLines) 1208 { 1209 gtk_text_view_set_pixels_above_lines(gtkTextView, pixelsAboveLines); 1210 } 1211 1212 /** 1213 * Sets the default number of pixels of blank space 1214 * to put below paragraphs in @text_view. 1215 * 1216 * May be overridden by tags applied to @text_view’s buffer. 1217 * 1218 * Params: 1219 * pixelsBelowLines = pixels below paragraphs 1220 */ 1221 public void setPixelsBelowLines(int pixelsBelowLines) 1222 { 1223 gtk_text_view_set_pixels_below_lines(gtkTextView, pixelsBelowLines); 1224 } 1225 1226 /** 1227 * Sets the default number of pixels of blank space to leave between 1228 * display/wrapped lines within a paragraph. 1229 * 1230 * May be overridden by tags in @text_view’s buffer. 1231 * 1232 * Params: 1233 * pixelsInsideWrap = default number of pixels between wrapped lines 1234 */ 1235 public void setPixelsInsideWrap(int pixelsInsideWrap) 1236 { 1237 gtk_text_view_set_pixels_inside_wrap(gtkTextView, pixelsInsideWrap); 1238 } 1239 1240 /** 1241 * Sets the default right margin for text in the text view. 1242 * 1243 * Tags in the buffer may override the default. 1244 * 1245 * Note that this function is confusingly named. 1246 * In CSS terms, the value set here is padding. 1247 * 1248 * Params: 1249 * rightMargin = right margin in pixels 1250 */ 1251 public void setRightMargin(int rightMargin) 1252 { 1253 gtk_text_view_set_right_margin(gtkTextView, rightMargin); 1254 } 1255 1256 /** 1257 * Sets the default tab stops for paragraphs in @text_view. 1258 * 1259 * Tags in the buffer may override the default. 1260 * 1261 * Params: 1262 * tabs = tabs as a `PangoTabArray` 1263 */ 1264 public void setTabs(PgTabArray tabs) 1265 { 1266 gtk_text_view_set_tabs(gtkTextView, (tabs is null) ? null : tabs.getPgTabArrayStruct()); 1267 } 1268 1269 /** 1270 * Sets the top margin for text in @text_view. 1271 * 1272 * Note that this function is confusingly named. 1273 * In CSS terms, the value set here is padding. 1274 * 1275 * Params: 1276 * topMargin = top margin in pixels 1277 */ 1278 public void setTopMargin(int topMargin) 1279 { 1280 gtk_text_view_set_top_margin(gtkTextView, topMargin); 1281 } 1282 1283 /** 1284 * Sets the line wrapping for the view. 1285 * 1286 * Params: 1287 * wrapMode = a `GtkWrapMode` 1288 */ 1289 public void setWrapMode(GtkWrapMode wrapMode) 1290 { 1291 gtk_text_view_set_wrap_mode(gtkTextView, wrapMode); 1292 } 1293 1294 /** 1295 * Determines whether @iter is at the start of a display line. 1296 * 1297 * See [method@Gtk.TextView.forward_display_line] for an 1298 * explanation of display lines vs. paragraphs. 1299 * 1300 * Params: 1301 * iter = a `GtkTextIter` 1302 * 1303 * Returns: %TRUE if @iter begins a wrapped line 1304 */ 1305 public bool startsDisplayLine(TextIter iter) 1306 { 1307 return gtk_text_view_starts_display_line(gtkTextView, (iter is null) ? null : iter.getTextIterStruct()) != 0; 1308 } 1309 1310 /** 1311 * Converts coordinates on the window identified by @win to buffer 1312 * coordinates. 1313 * 1314 * Params: 1315 * win = a `GtkTextWindowType` 1316 * windowX = window x coordinate 1317 * windowY = window y coordinate 1318 * bufferX = buffer x coordinate return location 1319 * bufferY = buffer y coordinate return location 1320 */ 1321 public void windowToBufferCoords(GtkTextWindowType win, int windowX, int windowY, out int bufferX, out int bufferY) 1322 { 1323 gtk_text_view_window_to_buffer_coords(gtkTextView, win, windowX, windowY, &bufferX, &bufferY); 1324 } 1325 1326 /** 1327 * Gets emitted when the user asks for it. 1328 * 1329 * The ::backspace signal is a [keybinding signal](class.SignalAction.html). 1330 * 1331 * The default bindings for this signal are 1332 * <kbd>Backspace</kbd> and <kbd>Shift</kbd>-<kbd>Backspace</kbd>. 1333 */ 1334 gulong addOnBackspace(void delegate(TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1335 { 1336 return Signals.connect(this, "backspace", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1337 } 1338 1339 /** 1340 * Gets emitted to copy the selection to the clipboard. 1341 * 1342 * The ::copy-clipboard signal is a [keybinding signal](class.SignalAction.html). 1343 * 1344 * The default bindings for this signal are 1345 * <kbd>Ctrl</kbd>-<kbd>c</kbd> and 1346 * <kbd>Ctrl</kbd>-<kbd>Insert</kbd>. 1347 */ 1348 gulong addOnCopyClipboard(void delegate(TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1349 { 1350 return Signals.connect(this, "copy-clipboard", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1351 } 1352 1353 /** 1354 * Gets emitted to cut the selection to the clipboard. 1355 * 1356 * The ::cut-clipboard signal is a [keybinding signal](class.SignalAction.html). 1357 * 1358 * The default bindings for this signal are 1359 * <kbd>Ctrl</kbd>-<kbd>x</kbd> and 1360 * <kbd>Shift</kbd>-<kbd>Delete</kbd>. 1361 */ 1362 gulong addOnCutClipboard(void delegate(TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1363 { 1364 return Signals.connect(this, "cut-clipboard", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1365 } 1366 1367 /** 1368 * Gets emitted when the user initiates a text deletion. 1369 * 1370 * The ::delete-from-cursor signal is a [keybinding signal](class.SignalAction.html). 1371 * 1372 * If the @type is %GTK_DELETE_CHARS, GTK deletes the selection 1373 * if there is one, otherwise it deletes the requested number 1374 * of characters. 1375 * 1376 * The default bindings for this signal are <kbd>Delete</kbd> for 1377 * deleting a character, <kbd>Ctrl</kbd>-<kbd>Delete</kbd> for 1378 * deleting a word and <kbd>Ctrl</kbd>-<kbd>Backspace</kbd> for 1379 * deleting a word backwards. 1380 * 1381 * Params: 1382 * type = the granularity of the deletion, as a `GtkDeleteType` 1383 * count = the number of @type units to delete 1384 */ 1385 gulong addOnDeleteFromCursor(void delegate(GtkDeleteType, int, TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1386 { 1387 return Signals.connect(this, "delete-from-cursor", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1388 } 1389 1390 /** 1391 * Emitted when the selection needs to be extended at @location. 1392 * 1393 * Params: 1394 * granularity = the granularity type 1395 * location = the location where to extend the selection 1396 * start = where the selection should start 1397 * end = where the selection should end 1398 * 1399 * Returns: %GDK_EVENT_STOP to stop other handlers from being invoked for the 1400 * event. %GDK_EVENT_PROPAGATE to propagate the event further. 1401 */ 1402 gulong addOnExtendSelection(bool delegate(GtkTextExtendSelection, TextIter, TextIter, TextIter, TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1403 { 1404 return Signals.connect(this, "extend-selection", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1405 } 1406 1407 /** 1408 * Gets emitted when the user initiates the insertion of a 1409 * fixed string at the cursor. 1410 * 1411 * The ::insert-at-cursor signal is a [keybinding signal](class.SignalAction.html). 1412 * 1413 * This signal has no default bindings. 1414 * 1415 * Params: 1416 * string_ = the string to insert 1417 */ 1418 gulong addOnInsertAtCursor(void delegate(string, TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1419 { 1420 return Signals.connect(this, "insert-at-cursor", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1421 } 1422 1423 /** 1424 * Gets emitted to present the Emoji chooser for the @text_view. 1425 * 1426 * The ::insert-emoji signal is a [keybinding signal](class.SignalAction.html). 1427 * 1428 * The default bindings for this signal are 1429 * <kbd>Ctrl</kbd>-<kbd>.</kbd> and 1430 * <kbd>Ctrl</kbd>-<kbd>;</kbd> 1431 */ 1432 gulong addOnInsertEmoji(void delegate(TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1433 { 1434 return Signals.connect(this, "insert-emoji", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1435 } 1436 1437 /** 1438 * Gets emitted when the user initiates a cursor movement. 1439 * 1440 * The ::move-cursor signal is a [keybinding signal](class.SignalAction.html). 1441 * If the cursor is not visible in @text_view, this signal causes 1442 * the viewport to be moved instead. 1443 * 1444 * Applications should not connect to it, but may emit it with 1445 * g_signal_emit_by_name() if they need to control the cursor 1446 * programmatically. 1447 * 1448 * 1449 * The default bindings for this signal come in two variants, 1450 * the variant with the <kbd>Shift</kbd> modifier extends the 1451 * selection, the variant without it does not. 1452 * There are too many key combinations to list them all here. 1453 * 1454 * - <kbd>←</kbd>, <kbd>→</kbd>, <kbd>↑</kbd>, <kbd>↓</kbd> 1455 * move by individual characters/lines 1456 * - <kbd>Ctrl</kbd>-<kbd>→</kbd>, etc. move by words/paragraphs 1457 * - <kbd>Home</kbd>, <kbd>End</kbd> move to the ends of the buffer 1458 * - <kbd>PgUp</kbd>, <kbd>PgDn</kbd> move vertically by pages 1459 * - <kbd>Ctrl</kbd>-<kbd>PgUp</kbd>, <kbd>Ctrl</kbd>-<kbd>PgDn</kbd> 1460 * move horizontally by pages 1461 * 1462 * Params: 1463 * step = the granularity of the move, as a `GtkMovementStep` 1464 * count = the number of @step units to move 1465 * extendSelection = %TRUE if the move should extend the selection 1466 */ 1467 gulong addOnMoveCursor(void delegate(GtkMovementStep, int, bool, TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1468 { 1469 return Signals.connect(this, "move-cursor", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1470 } 1471 1472 /** 1473 * Gets emitted to move the viewport. 1474 * 1475 * The ::move-viewport signal is a [keybinding signal](class.SignalAction.html), 1476 * which can be bound to key combinations to allow the user to move the viewport, 1477 * i.e. change what part of the text view is visible in a containing scrolled 1478 * window. 1479 * 1480 * There are no default bindings for this signal. 1481 * 1482 * Params: 1483 * step = the granularity of the movement, as a `GtkScrollStep` 1484 * count = the number of @step units to move 1485 */ 1486 gulong addOnMoveViewport(void delegate(GtkScrollStep, int, TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1487 { 1488 return Signals.connect(this, "move-viewport", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1489 } 1490 1491 /** 1492 * Gets emitted to paste the contents of the clipboard 1493 * into the text view. 1494 * 1495 * The ::paste-clipboard signal is a [keybinding signal](class.SignalAction.html). 1496 * 1497 * The default bindings for this signal are 1498 * <kbd>Ctrl</kbd>-<kbd>v</kbd> and 1499 * <kbd>Shift</kbd>-<kbd>Insert</kbd>. 1500 */ 1501 gulong addOnPasteClipboard(void delegate(TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1502 { 1503 return Signals.connect(this, "paste-clipboard", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1504 } 1505 1506 /** 1507 * Emitted when preedit text of the active IM changes. 1508 * 1509 * If an input method is used, the typed text will not immediately 1510 * be committed to the buffer. So if you are interested in the text, 1511 * connect to this signal. 1512 * 1513 * This signal is only emitted if the text at the given position 1514 * is actually editable. 1515 * 1516 * Params: 1517 * preedit = the current preedit string 1518 */ 1519 gulong addOnPreeditChanged(void delegate(string, TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1520 { 1521 return Signals.connect(this, "preedit-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1522 } 1523 1524 /** 1525 * Gets emitted to select or unselect the complete contents of the text view. 1526 * 1527 * The ::select-all signal is a [keybinding signal](class.SignalAction.html). 1528 * 1529 * The default bindings for this signal are 1530 * <kbd>Ctrl</kbd>-<kbd>a</kbd> and 1531 * <kbd>Ctrl</kbd>-<kbd>/</kbd> for selecting and 1532 * <kbd>Shift</kbd>-<kbd>Ctrl</kbd>-<kbd>a</kbd> and 1533 * <kbd>Ctrl</kbd>-<kbd>\</kbd> for unselecting. 1534 * 1535 * Params: 1536 * select = %TRUE to select, %FALSE to unselect 1537 */ 1538 gulong addOnSelectAll(void delegate(bool, TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1539 { 1540 return Signals.connect(this, "select-all", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1541 } 1542 1543 /** 1544 * Gets emitted when the user initiates settings the "anchor" mark. 1545 * 1546 * The ::set-anchor signal is a [keybinding signal](class.SignalAction.html) 1547 * which gets emitted when the user initiates setting the "anchor" 1548 * mark. The "anchor" mark gets placed at the same position as the 1549 * "insert" mark. 1550 * 1551 * This signal has no default bindings. 1552 */ 1553 gulong addOnSetAnchor(void delegate(TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1554 { 1555 return Signals.connect(this, "set-anchor", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1556 } 1557 1558 /** 1559 * Gets emitted to toggle the `cursor-visible` property. 1560 * 1561 * The ::toggle-cursor-visible signal is a 1562 * [keybinding signal](class.SignalAction.html). 1563 * 1564 * The default binding for this signal is <kbd>F7</kbd>. 1565 */ 1566 gulong addOnToggleCursorVisible(void delegate(TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1567 { 1568 return Signals.connect(this, "toggle-cursor-visible", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1569 } 1570 1571 /** 1572 * Gets emitted to toggle the overwrite mode of the text view. 1573 * 1574 * The ::toggle-overwrite signal is a [keybinding signal](class.SignalAction.html). 1575 * 1576 * The default binding for this signal is <kbd>Insert</kbd>. 1577 */ 1578 gulong addOnToggleOverwrite(void delegate(TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1579 { 1580 return Signals.connect(this, "toggle-overwrite", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1581 } 1582 }